home *** CD-ROM | disk | FTP | other *** search
- import java.io.IOException;
- import javax.microedition.lcdui.Graphics;
- import javax.microedition.lcdui.Image;
-
- public class Bullet {
- public static final int STATE_LIVE = 0;
- public static final int STATE_EXPLOSION = 1;
- public static final int STATE_KILL = 2;
- // $FF: renamed from: dx int
- private int field_0;
- // $FF: renamed from: dy int
- private int field_1;
- private int dx2;
- private int dy2;
- private int x_inc;
- private int y_inc;
- private int error;
- private int index;
- private int shot;
- private int positionX = 0;
- private int positionY = 0;
- private int state = 2;
- private int frame = 0;
- private int idBullet;
- public static Image[] image;
-
- public Bullet(int var1) {
- this.idBullet = var1;
- }
-
- protected boolean CheckCollision(Gun var1) {
- int var2 = ((Sprite)var1).getPositionX();
- int var3 = ((Sprite)var1).getPositionY();
- int var4 = ((Sprite)var1).getWidth();
- int var5 = ((Sprite)var1).getHeight();
- return (var2 > this.positionX && var2 < this.positionX + 7 || this.positionX > var2 && this.positionX < var2 + var4) && (var3 > this.positionY && var3 < this.positionY + 7 || this.positionY > var3 && this.positionY < var3 + var5);
- }
-
- public int GetState() {
- return this.state;
- }
-
- public void Initialize(int var1, int var2, int var3, int var4, int var5) {
- this.positionX = var1;
- this.positionY = var2;
- this.field_0 = var3 - var1;
- this.field_1 = var4 - var2;
- this.state = 0;
- if (this.field_0 >= 0) {
- this.x_inc = var5;
- } else {
- this.x_inc = -var5;
- this.field_0 = -this.field_0;
- }
-
- if (this.field_1 >= 0) {
- this.y_inc = var5;
- } else {
- this.y_inc = -var5;
- this.field_1 = -this.field_1;
- }
-
- this.dx2 = this.field_0 << 1;
- this.dy2 = this.field_1 << 1;
- this.index = 0;
- if (this.field_0 > this.field_1) {
- this.shot = 1;
- this.error = this.dy2 - this.field_0;
- } else {
- this.shot = 2;
- this.error = this.dx2 - this.field_1;
- }
-
- }
-
- public void SetState(int var1) {
- this.state = var1;
- }
-
- public void draw(Graphics var1) {
- if (this.state == 0) {
- var1.setColor(255, 255, 0);
- var1.fillRect(this.positionX, this.positionY, 2, 2);
- } else if (this.state == 1) {
- if (this.frame == 0) {
- this.positionX -= 3;
- this.positionY -= 3;
- }
-
- var1.drawImage(image[this.frame], this.positionX, this.positionY, 20);
- ++this.frame;
- if (this.frame == 3) {
- this.state = 2;
- this.frame = 0;
- }
- }
-
- }
-
- public int getPositionX() {
- return this.positionX;
- }
-
- public int getPositionY() {
- return this.positionY;
- }
-
- public static void initResources() throws IOException {
- image = new Image[3];
-
- for(int var0 = 0; var0 < 3; ++var0) {
- image[var0] = Image.createImage("/expl" + var0 + ".png");
- }
-
- }
-
- public void setPosition(int var1, int var2) {
- this.positionX = var1;
- this.positionY = var2;
- }
-
- public void update() {
- if (this.state == 0) {
- if (this.shot == 1) {
- if (this.error >= 0) {
- this.error = -this.dx2;
- this.positionY += this.y_inc;
- }
-
- this.error += this.dy2;
- this.positionX += this.x_inc;
- this.index += Math.abs(this.x_inc);
- if (this.index > this.field_0) {
- this.state = 1;
- }
- } else {
- if (this.error >= 0) {
- this.error = -this.dy2;
- this.positionX += this.x_inc;
- }
-
- this.error += this.dx2;
- this.positionY += this.y_inc;
- this.index += Math.abs(this.y_inc);
- if (this.index > this.field_1) {
- this.state = 1;
- }
- }
- }
-
- }
- }
-